package com.jron.cqiu.kernel.regist;

import com.jron.cqiu.util.Instance;
import jnacontrib.win32.Registry.REGISTRY_ROOT_KEY;

import java.util.TreeMap;

/**
 * Created by Intellij IDEA.
 *
 * @Author: Yejw
 * @Date: 2008-6-13
 * @Time: 17:24:07
 */
public interface IRegist {

    /**
     * IRegist 默认实现
     */
    IRegist INSTANCE = Instance.REGIST_JNA_INSTANCE;

    /**
     * Read a String value.
     *
     * @param rootKey    root key
     * @param subKeyName key name
     * @param name       value name
     * @return String or null
     */
    public String getStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name);

    /**
     * Read an int value.
     *
     * @param rootKey    root key
     * @param subKeyName key name
     * @param name       value name
     * @return int or 0
     */
    public int getIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name);

    /**
     * Delete a value.
     *
     * @param rootKey    root key
     * @param subKeyName key name
     * @param name       value name
     * @return true on success
     */
    public boolean deleteValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name);

    /**
     * Writes a String value.
     *
     * @param rootKey    root key
     * @param subKeyName key name
     * @param name       value name
     * @param value      value
     * @return true on success
     */
    public boolean setStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, String value);

    /**
     * Writes an int value.
     *
     * @param rootKey    root key
     * @param subKeyName key name
     * @param name       value name
     * @param value      value
     * @return true on success
     */
    public boolean setIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, int value);

    /**
     * Check for existence of a value.
     *
     * @param rootKey    root key
     * @param subKeyName key name
     * @param name       value name
     * @return true if exists
     */
    public boolean valueExists(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name);

    /**
     * Create a new key.
     *
     * @param rootKey root key
     * @param parent  name of parent key
     * @param name    key name
     * @return true on success
     */
    public boolean createKey(REGISTRY_ROOT_KEY rootKey, String parent, String name);

    /**
     * Delete a key.
     *
     * @param rootKey root key
     * @param parent  name of parent key
     * @param name    key name
     * @return true on success
     */
    public boolean deleteKey(REGISTRY_ROOT_KEY rootKey, String parent, String name);

    /**
     * Get all sub keys of a key.
     *
     * @param rootKey root key
     * @param parent  key name
     * @return array with all sub key names
     */
    public String[] getSubKeys(REGISTRY_ROOT_KEY rootKey, String parent);

    /**
     * Get all values under a key.
     *
     * @param rootKey root key
     * @param key     jey name
     * @return TreeMap with name and value pairs on error
     */
    public TreeMap<String, Object> getValues(REGISTRY_ROOT_KEY rootKey, String key);
}
